<template>
  <!-- 评论 -->
  <div class="commentPopup">
    <div class="comment_list">
      <p>评论区({{ totalCount }})</p>
      <div>
        <span @click="onSortType(1)" :class="sortType == '1' ? 'current' : ''"
          >推荐</span
        >
        <span @click="onSortType(2)" :class="sortType == '2' ? 'current' : ''"
          >最热</span
        >
        <span @click="onSortType(3)" :class="sortType == '3' ? 'current' : ''"
          >最新</span
        >
      </div>
    </div>
    <Comment @loadTotalCount="totalCount = $event" :id="id" :type="type" :sortType="sortType" />
    <FloorCommentList :id="id" :type="type" />
  </div>
</template>

<script>
import FloorCommentList from './FloorCommentList.vue'
import Comment from './Comment.vue'

export default {
  name: 'CommentList',
  data () {
    return {
      sortType: 1, // 按什么排序
      isShowPopup: false,
      totalCount: 0
    }
  },
  components: {
    Comment,
    FloorCommentList
  },
  props: {
    id: {
      type: [Number, String],
      required: true
    },
    type: {
      type: Number,
      required: true
    }
  },
  // 定义方法
  methods: {
    // 更换评论类型
    onSortType (t) {
      this.sortType = t
    }
  }
}
</script>

<style scoped lang="less">
.commentPopup {
  .comment_list {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #333;
    font-weight: 700;
    margin: 0px 0 10px;
    padding: 0 20px;
    span {
      font-weight: 400;
      color: #999;
      margin-left: 20px;
    }
    .current {
      font-weight: 700;
      color: #333;
    }
  }
}
</style>
